/**
 * 添加或者修改页面
 */
var TurnoverContainerInfoDlg = {
    data: {
        packId: "",
        packNumber: "",
        storageState: "",
        attribute: "",
        specifications: "",
        operator: "",
        sendTime: "",
        warehouseId: "",
        warehouseName: "",
        deptId: "",
        deliverId: "",
        v1: "",
        v2: "",
        v3: ""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    // 绑定点击事件，获取当前时间
    var currentDate = new Date();

    // 获取年、月、日、时、分、秒
    var year = currentDate.getFullYear(); // 年份
    var month = ('0' + (currentDate.getMonth() + 1)).slice(-2); // 月份，注意加1，月份从0开始
    var day = ('0' + currentDate.getDate()).slice(-2); // 日期
    var hours = ('0' + currentDate.getHours()).slice(-2); // 小时
    var minutes = ('0' + currentDate.getMinutes()).slice(-2); // 分钟
    var seconds = ('0' + currentDate.getSeconds()).slice(-2); // 秒钟

    // 格式化成字符串，例如：2024-04-28 15:30:00
    var formattedDateTime = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;

    // 打印结果
    $('#sendTime').val(formattedDateTime); // 将当前时间填充到输入框中
    $('#storageState').val("初始化");


    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/turnoverContainer/addItem", function (data) {
            Feng.success("添加成功！");
            window.location.href = Feng.ctxPath + '/turnoverContainer'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/turnoverContainer'
    });

});